how to handle exceptions in selenium